import pygame
from game_items import *
from game_hud import *
from game_music import *

class Game(object):
    '''游戏类'''

    def __init__(self):  # 构造方法
        # 游戏主窗口
        self.main_windown = pygame.display.set_mode(SCREEN_RECT.size)
        pygame.display.set_caption("飞机大战")
        # 游戏状态属性
        self.is_game_over = True
        self.is_pause = False
    def reset_game(self):
        '''重置游戏'''
        self.is_game_over = False
        self.is_pause = False
    def event_handler(self):
        '''事件监听'''

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                return True
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                return True
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:
                if self.is_game_over:  # 游戏已经结束
                    self.reset_game()  # 重新开始游戏
                else:
                    self.is_pause = not self.is_pause
        return False
    def start(self):
        '''开始游戏'''
        clock = pygame.time.Clock()
        while True:
            if self.is_game_over:
                print("游戏已经结束，按空格键重新开始")
            elif self.is_pause:
                print("游戏已经暂停，按空格键继续")
            else:
                print("游戏进行中")
            pygame.display.update()  # 更新显示
            clock.tick(60)
if __name__ == '__main__':
    pygame.init()

    Game().start()

    pygame.quit()